import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useEmployeeStore = defineStore(
  'sp-employee',
  () => {
    const employeeInfo = ref()

    const setEmployeeInfo = (newInfo) => {
      //排除不要属性
      let info = { ...newInfo }
      delete info.createEmployee
      delete info.createEmployeeName
      delete info.createTime
      delete info.updateEmployee
      delete info.updateEmployeeName
      delete info.updateTime
      employeeInfo.value = info
    }

    const removeEmployeeInfo = () => {
      employeeInfo.value = {}
    }

    return {
      employeeInfo,
      setEmployeeInfo,
      removeEmployeeInfo
    }
  },
  {
    persist: {
      paths: ['employeeInfo']
    }
  }
)
